




/*
'===============================================================================
'  HNG.Portal.BL.TblMediaCategoryManagerBase
'===============================================================================
*/

using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using HNG.Portal.BLL;
using HNG.Portal.DAL;
using HNG.Portal.DAL.EntityClasses;
using HNG.Portal.DAL.FactoryClasses;
using HNG.Portal.DAL.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;
using System.Windows.Forms;
namespace HNG.Portal.BLL
{
	public class TblMediaCategoryManagerBase
	{
	    
		#region ColumnNames
		
				public const String Field_Id="Id";
				
				public const String Field_LangId="LangId";
				
				public const String Field_DanhMucCha="DanhMucCha";
				
				public const String Field_TenDanhMucCha="TenDanhMucCha";
				
				public const String Field_TenDanhMuc="TenDanhMuc";
				
				public const String Field_ThuTu="ThuTu";
				
				public const String Field_ViTri="ViTri";
				
				public const String Field_MoTa="MoTa";
				
				public const String Field_Url="Url";
				
				public const String Field_Icon="Icon";
				
				public const String Field_Type="Type";
				
				public const String Field_IsHome="IsHome";
				
				public const String Field_TrangThai="TrangThai";
				
		#endregion	
		/// <summary>
		/// Purpose: Class constructor.
		/// </summary>
		public TblMediaCategoryManagerBase()
		{
			// Nothing for now.
		}
		public DataTable Clone()
		{
			DataTable dt = new DataTable();
						
			
			dt.Columns.Add(Field_Id,typeof(int));
			
						
			
			dt.Columns.Add(Field_LangId,typeof(string));
			
						
			
			dt.Columns.Add(Field_DanhMucCha,typeof(int));
			
						
			
			dt.Columns.Add(Field_TenDanhMucCha,typeof(string));
			
						
			
			dt.Columns.Add(Field_TenDanhMuc,typeof(string));
			
						
			
			dt.Columns.Add(Field_ThuTu,typeof(int));
			
						
			
			dt.Columns.Add(Field_ViTri,typeof(string));
			
						
			
			dt.Columns.Add(Field_MoTa,typeof(string));
			
						
			
			dt.Columns.Add(Field_Url,typeof(string));
			
						
			
			dt.Columns.Add(Field_Icon,typeof(string));
			
						
			
			dt.Columns.Add(Field_Type,typeof(string));
			
						
			
			dt.Columns.Add(Field_IsHome,typeof(bool));
			
						
			
			dt.Columns.Add(Field_TrangThai,typeof(bool));
			
			            
            return dt;			
		}
			
		public TblMediaCategoryEntity Convert_Entity(TblMediaCategoryEntity _TblMediaCategoryEntity,TblMediaCategoryEntity _TblMediaCategoryEntity_XML)
		{	
			
				
			_TblMediaCategoryEntity.Id= _TblMediaCategoryEntity_XML.Id;
				
			_TblMediaCategoryEntity.LangId= _TblMediaCategoryEntity_XML.LangId;
				
			_TblMediaCategoryEntity.DanhMucCha= _TblMediaCategoryEntity_XML.DanhMucCha;
				
			_TblMediaCategoryEntity.TenDanhMucCha= _TblMediaCategoryEntity_XML.TenDanhMucCha;
				
			_TblMediaCategoryEntity.TenDanhMuc= _TblMediaCategoryEntity_XML.TenDanhMuc;
				
			_TblMediaCategoryEntity.ThuTu= _TblMediaCategoryEntity_XML.ThuTu;
				
			_TblMediaCategoryEntity.ViTri= _TblMediaCategoryEntity_XML.ViTri;
				
			_TblMediaCategoryEntity.MoTa= _TblMediaCategoryEntity_XML.MoTa;
				
			_TblMediaCategoryEntity.Url= _TblMediaCategoryEntity_XML.Url;
				
			_TblMediaCategoryEntity.Icon= _TblMediaCategoryEntity_XML.Icon;
				
			_TblMediaCategoryEntity.Type= _TblMediaCategoryEntity_XML.Type;
				
			_TblMediaCategoryEntity.IsHome= _TblMediaCategoryEntity_XML.IsHome;
				
			_TblMediaCategoryEntity.TrangThai= _TblMediaCategoryEntity_XML.TrangThai;
				
			
			return _TblMediaCategoryEntity;
		}	
		
			
		public void InsertCollection(EntityCollection _Collection)
		{
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
            {
                adapter.SaveEntityCollection(_Collection);
            }
		}

		public TblMediaCategoryEntity Insert(TblMediaCategoryEntity TblMediaCategoryEntity)
		{
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.SaveEntity(TblMediaCategoryEntity, true);
			}
			return TblMediaCategoryEntity;
		}

		
		public TblMediaCategoryEntity Insert(int Id, string LangId, int DanhMucCha, string TenDanhMucCha, string TenDanhMuc, int ThuTu, string ViTri, string MoTa, string Url, string Icon, string Type, bool IsHome, bool TrangThai)
		{
			TblMediaCategoryEntity _TblMediaCategoryEntity = new TblMediaCategoryEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_TblMediaCategoryEntity.Id = Id;
				_TblMediaCategoryEntity.LangId = LangId;
				_TblMediaCategoryEntity.DanhMucCha = DanhMucCha;
				_TblMediaCategoryEntity.TenDanhMucCha = TenDanhMucCha;
				_TblMediaCategoryEntity.TenDanhMuc = TenDanhMuc;
				_TblMediaCategoryEntity.ThuTu = ThuTu;
				_TblMediaCategoryEntity.ViTri = ViTri;
				_TblMediaCategoryEntity.MoTa = MoTa;
				_TblMediaCategoryEntity.Url = Url;
				_TblMediaCategoryEntity.Icon = Icon;
				_TblMediaCategoryEntity.Type = Type;
				_TblMediaCategoryEntity.IsHome = IsHome;
				_TblMediaCategoryEntity.TrangThai = TrangThai;
				adapter.SaveEntity(_TblMediaCategoryEntity, true);
			}
			return _TblMediaCategoryEntity;
		}

		public TblMediaCategoryEntity Insert(string LangId, int DanhMucCha, string TenDanhMucCha, string TenDanhMuc, int ThuTu, string ViTri, string MoTa, string Url, string Icon, string Type, bool IsHome, bool TrangThai)
		{
			TblMediaCategoryEntity _TblMediaCategoryEntity = new TblMediaCategoryEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_TblMediaCategoryEntity.LangId = LangId;
				_TblMediaCategoryEntity.DanhMucCha = DanhMucCha;
				_TblMediaCategoryEntity.TenDanhMucCha = TenDanhMucCha;
				_TblMediaCategoryEntity.TenDanhMuc = TenDanhMuc;
				_TblMediaCategoryEntity.ThuTu = ThuTu;
				_TblMediaCategoryEntity.ViTri = ViTri;
				_TblMediaCategoryEntity.MoTa = MoTa;
				_TblMediaCategoryEntity.Url = Url;
				_TblMediaCategoryEntity.Icon = Icon;
				_TblMediaCategoryEntity.Type = Type;
				_TblMediaCategoryEntity.IsHome = IsHome;
				_TblMediaCategoryEntity.TrangThai = TrangThai;
				adapter.SaveEntity(_TblMediaCategoryEntity, true);
			}
			return _TblMediaCategoryEntity;
		}

		public bool Update(TblMediaCategoryEntity _TblMediaCategoryEntity)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				RelationPredicateBucket filter = new RelationPredicateBucket();
				IPredicateExpression _PredicateExpression = new PredicateExpression();
				_PredicateExpression.Add(TblMediaCategoryFields.Id == _TblMediaCategoryEntity.Id);
					
				filter.PredicateExpression.Add(_PredicateExpression);

				adapter.UpdateEntitiesDirectly(_TblMediaCategoryEntity, filter);
				toReturn = true;
			}
			return toReturn;
		}
		
		public bool Update(TblMediaCategoryEntity _TblMediaCategoryEntity, RelationPredicateBucket filter)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.UpdateEntitiesDirectly(_TblMediaCategoryEntity, filter);
				toReturn = true;
			}
			return toReturn;
		}

		public bool Update(int Id, string LangId, int DanhMucCha, string TenDanhMucCha, string TenDanhMuc, int ThuTu, string ViTri, string MoTa, string Url, string Icon, string Type, bool IsHome, bool TrangThai)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				TblMediaCategoryEntity _TblMediaCategoryEntity = new TblMediaCategoryEntity(Id);
				if (adapter.FetchEntity(_TblMediaCategoryEntity))
				{
				
					_TblMediaCategoryEntity.LangId = LangId;
					_TblMediaCategoryEntity.DanhMucCha = DanhMucCha;
					_TblMediaCategoryEntity.TenDanhMucCha = TenDanhMucCha;
					_TblMediaCategoryEntity.TenDanhMuc = TenDanhMuc;
					_TblMediaCategoryEntity.ThuTu = ThuTu;
					_TblMediaCategoryEntity.ViTri = ViTri;
					_TblMediaCategoryEntity.MoTa = MoTa;
					_TblMediaCategoryEntity.Url = Url;
					_TblMediaCategoryEntity.Icon = Icon;
					_TblMediaCategoryEntity.Type = Type;
					_TblMediaCategoryEntity.IsHome = IsHome;
					_TblMediaCategoryEntity.TrangThai = TrangThai;
					adapter.SaveEntity(_TblMediaCategoryEntity, true);
					toReturn = true;
				}
			}
			return toReturn;
		}

		public bool Delete(int Id)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				TblMediaCategoryEntity _TblMediaCategoryEntity = new TblMediaCategoryEntity(Id);
				if (adapter.FetchEntity(_TblMediaCategoryEntity))
				{
					adapter.DeleteEntity(_TblMediaCategoryEntity);
					toReturn = true;
				}
			}
			return toReturn;
		}
		
		public void DeleteAll() 
		{
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.DeleteEntitiesDirectly("TblMediaCategoryEntity", null);
			}
		}
		
		
		public int DeleteById(int Id)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMediaCategoryEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByLangId(string LangId)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.LangId == LangId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMediaCategoryEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByDanhMucCha(int DanhMucCha)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.DanhMucCha == DanhMucCha);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMediaCategoryEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByTenDanhMucCha(string TenDanhMucCha)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.TenDanhMucCha == TenDanhMucCha);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMediaCategoryEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByTenDanhMuc(string TenDanhMuc)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.TenDanhMuc == TenDanhMuc);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMediaCategoryEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByThuTu(int ThuTu)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.ThuTu == ThuTu);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMediaCategoryEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByViTri(string ViTri)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.ViTri == ViTri);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMediaCategoryEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByMoTa(string MoTa)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.MoTa == MoTa);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMediaCategoryEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByUrl(string Url)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.Url == Url);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMediaCategoryEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByIcon(string Icon)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.Icon == Icon);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMediaCategoryEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByType(string Type)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.Type == Type);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMediaCategoryEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByIsHome(bool IsHome)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.IsHome == IsHome);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMediaCategoryEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByTrangThai(bool TrangThai)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.TrangThai == TrangThai);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMediaCategoryEntity", filter);
			}
			return toReturn;
		}
		

		
		public TblMediaCategoryEntity SelectOne(int Id)
		{
			TblMediaCategoryEntity toReturn = null;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				TblMediaCategoryEntity _TblMediaCategoryEntity = new TblMediaCategoryEntity(Id);
				if (adapter.FetchEntity(_TblMediaCategoryEntity))
				{
					toReturn = _TblMediaCategoryEntity;
				}
			}
			return toReturn;
		}

		// Return EntityCollection
		public EntityCollection SelectAll()
		{
			EntityCollection _TblMediaCategoryCollection = new EntityCollection( new TblMediaCategoryEntityFactory());
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMediaCategoryCollection, null, 0, null);
			}
			return _TblMediaCategoryCollection;
		}
		
		// Return DataTable
		public DataTable SelectAllRDT()
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMediaCategoryCollection.EntityFactoryToUse.CreateFields(), toReturn, null, true);
			}
			return toReturn;
		}

		
		// Return EntityCollection
		public EntityCollection SelectById(int Id)
		{
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMediaCategoryCollection, filter, 0, null);
			}
			return _TblMediaCategoryCollection;
		}
		
		// Return DataTable
		public DataTable SelectByIdRDT(int Id)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMediaCategoryCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByLangId(string LangId)
		{
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.LangId == LangId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMediaCategoryCollection, filter, 0, null);
			}
			return _TblMediaCategoryCollection;
		}
		
		// Return DataTable
		public DataTable SelectByLangIdRDT(string LangId)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.LangId == LangId);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMediaCategoryCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByDanhMucCha(int DanhMucCha)
		{
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.DanhMucCha == DanhMucCha);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMediaCategoryCollection, filter, 0, null);
			}
			return _TblMediaCategoryCollection;
		}
		
		// Return DataTable
		public DataTable SelectByDanhMucChaRDT(int DanhMucCha)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.DanhMucCha == DanhMucCha);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMediaCategoryCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByTenDanhMucCha(string TenDanhMucCha)
		{
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.TenDanhMucCha == TenDanhMucCha);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMediaCategoryCollection, filter, 0, null);
			}
			return _TblMediaCategoryCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTenDanhMucChaRDT(string TenDanhMucCha)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.TenDanhMucCha == TenDanhMucCha);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMediaCategoryCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByTenDanhMuc(string TenDanhMuc)
		{
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.TenDanhMuc == TenDanhMuc);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMediaCategoryCollection, filter, 0, null);
			}
			return _TblMediaCategoryCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTenDanhMucRDT(string TenDanhMuc)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.TenDanhMuc == TenDanhMuc);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMediaCategoryCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByThuTu(int ThuTu)
		{
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.ThuTu == ThuTu);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMediaCategoryCollection, filter, 0, null);
			}
			return _TblMediaCategoryCollection;
		}
		
		// Return DataTable
		public DataTable SelectByThuTuRDT(int ThuTu)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.ThuTu == ThuTu);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMediaCategoryCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByViTri(string ViTri)
		{
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.ViTri == ViTri);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMediaCategoryCollection, filter, 0, null);
			}
			return _TblMediaCategoryCollection;
		}
		
		// Return DataTable
		public DataTable SelectByViTriRDT(string ViTri)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.ViTri == ViTri);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMediaCategoryCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByMoTa(string MoTa)
		{
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.MoTa == MoTa);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMediaCategoryCollection, filter, 0, null);
			}
			return _TblMediaCategoryCollection;
		}
		
		// Return DataTable
		public DataTable SelectByMoTaRDT(string MoTa)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.MoTa == MoTa);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMediaCategoryCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByUrl(string Url)
		{
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.Url == Url);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMediaCategoryCollection, filter, 0, null);
			}
			return _TblMediaCategoryCollection;
		}
		
		// Return DataTable
		public DataTable SelectByUrlRDT(string Url)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.Url == Url);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMediaCategoryCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByIcon(string Icon)
		{
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.Icon == Icon);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMediaCategoryCollection, filter, 0, null);
			}
			return _TblMediaCategoryCollection;
		}
		
		// Return DataTable
		public DataTable SelectByIconRDT(string Icon)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.Icon == Icon);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMediaCategoryCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByType(string Type)
		{
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.Type == Type);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMediaCategoryCollection, filter, 0, null);
			}
			return _TblMediaCategoryCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTypeRDT(string Type)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.Type == Type);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMediaCategoryCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByIsHome(bool IsHome)
		{
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.IsHome == IsHome);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMediaCategoryCollection, filter, 0, null);
			}
			return _TblMediaCategoryCollection;
		}
		
		// Return DataTable
		public DataTable SelectByIsHomeRDT(bool IsHome)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.IsHome == IsHome);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMediaCategoryCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByTrangThai(bool TrangThai)
		{
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.TrangThai == TrangThai);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMediaCategoryCollection, filter, 0, null);
			}
			return _TblMediaCategoryCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTrangThaiRDT(bool TrangThai)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMediaCategoryCollection = new EntityCollection(new TblMediaCategoryEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMediaCategoryFields.TrangThai == TrangThai);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMediaCategoryCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		

	}
}
